<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}
$params = array();
array_push($params, pg_escape_string($_POST["id"]));
array_push($params, pg_escape_string(strtoupper($_POST["name"])));
array_push($params, pg_escape_string($_POST["detail"]));
array_push($params, pg_escape_string($_POST["price"]));

$stmt = pg_prepare($connect, "update_spend_spend", "UPDATE spend_spend SET name=$2,detail=$3,price=$4 WHERE id = $1 ");

$result = pg_execute($connect, "update_spend_spend", $params);

if (!$result) {

    die("Error in SQL query: " . pg_last_error());
}

echo "Data successfully inserted!";

pg_free_result($result);
pg_close($connect);